<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/tld/struts-bean" prefix="bean"%>
<%@ taglib uri="/WEB-INF/tld/struts-html" prefix="html"%>
<%@ taglib uri="/WEB-INF/tld/struts-logic" prefix="logic"%>
<%@ taglib uri="/WEB-INF/tld/jstl/c" prefix="c"%>
<%@ taglib uri="/WEB-INF/tld/jstl/fn" prefix="fn" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>短信息管理列表</title>
<style type="text/css">
.vb_wid {width:100%; margin: 0 auto; border-top:1px #FDB18D solid; background:#F5F5F5; color:#FE6500; text-indent:20px; line-height:25px; font-size:12px;}
.fb_search {width:90%; margin:0 auto; margin-top:20px; border:1px #FFCD7F solid;}
.fb_search h1 {background:#FFEFBB; margin:0px; padding:0px; line-height:28px; text-indent:10px; font-size:14px; height:28px;}
.fb_search h1 span {float:left;}
.fb_search h1 font {float: right; margin-right: 10px; font-size:12px; font-weight: normal;}
.fb_search h1 font a {color: #464646; text-decoration: none;}
.fb_s_a1 {margin:5px; font-size:14px; line-height:30px;}
.fb_s_a2 {font-size:12px; line-height:22px; color:#999; margin-left:5px;}
.fb_ddd {width:90%; margin:0 auto; margin-top:10px; border-top:3px #FFCC00 solid; background:url(images/pen.gif) no-repeat 5px 3px; height:40px; text-indent:50px; line-height:40px; color:#464646; font-size:12px;}
.fb_nr {width:90%; margin:0 auto; margin-top:10px; line-height:22px; font-size:12px; color:#464646}
.fb_nr span {color:#FF0000;}
.fb_nr select {color:464646; font-size:12px;}
.fb_nr Div {margin-top:10px; height:30px;}
.fb_nr Div input {font-size:12px; line-height:18px;}
.inputtttt {border:1px #DEA303 solid; height:20px; color:#464646; font-size:12px; background:url(images/bottom_bg.jpg) repeat-x left top;}
.lb {background:#FFCD7F; color:#464646; font-weight:bold; text-align:center; height:30px; line-height:30px;}
.lb1 {border-bottom:1px #000000 dashed; height:28px;}
.lb1 td {border-bottom:1px #ccc dashed; background:#eefefe}
.fy1 {width:90%; margin:0 auto; margin-top:8px; background:#F8F8F8; font-size:12px; height:30px; line-height:28px; text-indent:10px;}
.fy1 span {color:#FF0000; font-weight:bold;}
.fy1 a {color:#464646; text-decoration:none;}
.fy1 a:hover {color:#FF0000; text-decoration:underline;}

.fuj {width:90%; margin: 0 auto; font-size:12px; color:#464646; line-height:26px; border:1px #989898 solid; padding:5px;}
</style>


    <LINK title=win2k-cold-1 media=all href="/command/calendar/calendar-brown.css"  type=text/css rel=stylesheet>
	<SCRIPT src="/command/calendar/calendar.js" type=text/javascript></SCRIPT>
	<SCRIPT src="/command/calendar/calendar-en.js" type=text/javascript></SCRIPT>
	<SCRIPT src="/command/calendar/changebg.js" type=text/javascript></SCRIPT>
	<SCRIPT src="/command/calendar/calendar-setup.js" type=text/javascript></SCRIPT>
	

<script type="text/javascript">
 
 var choice;
 function selectAll(choice)
 {
   if(document.forms['ebbEmailManageForm'].checkboxparam.length!=null)
   {
	   for (var i=0;i<document.forms['ebbEmailManageForm'].checkboxparam.length;i++) 
	   {
			var e=document.forms['ebbEmailManageForm'].checkboxparam[i];
			if(choice==1)e.checked=true;
			if(choice==2)e.checked=(e.checked?false:true);
			if(choice==3)e.checked=false;
		}
   }
   //单个的处理
   else
   {
     var e=document.forms['ebbEmailManageForm'].checkboxparam;
     if(choice==1)e.checked=true;
			if(choice==2)e.checked=(e.checked?false:true);
			if(choice==3)e.checked=false;
     
   }
	
}


 
 var control;
 var page;
 function toPage(control,page)
 {
   var searchLink='/admin/ebbmail/ebbEmailManageAdmin.do?action=search';
   var toPageLink=document.getElementById('toPageLink').value;
   var toPageValue = document.getElementById('toPageValue').value;
   var link='';
    if(control!='toPage')
    {
       link=searchLink+toPageLink+'&page='+page;
    }
    else
    {
       link=searchLink+toPageLink+'&page='+toPageValue;
    }
    
    window.location=encodeURI(link);
 }
 
 
 //批量删除
 function deleteAll()
 {
       var searchLink='/admin/ebbmail/ebbEmailManageAdmin.do?action=dealWithAll&todo=delete';
       var toPageLink=document.getElementById('toPageLink').value;
       var curPage=document.getElementById('curPage').value;
    
       var param='';   
   if(document.forms['ebbEmailManageForm'].checkboxparam.length!=null)
   {
        for (var i=0;i<document.forms['ebbEmailManageForm'].checkboxparam.length;i++) 
		   {
		        var e=document.forms['ebbEmailManageForm'].checkboxparam[i];
		        if(e.checked)
		        {
					param += '&checkboxparam=' + e.value;
					flag = 1;
				}
		   }
		   if(flag==1)
		   {
		        
		   }
		   else
		   {
		        window.alert('至少选择一项!');
		        return false;
		   }
   }
   
   //只选择了一项
   else if(document.forms['ebbEmailManageForm'].checkboxparam!=null)
   {
       var e=document.forms['ebbEmailManageForm'].checkboxparam;
	        if(e.checked)
	        {
						param += '&checkboxparam=' + e.value;
						flag = 1;
		    }
	    
	      if(flag==1)
		   {
		   
           }
           else
           {
		        window.alert('至少选择一项!');
		        return false;
		   }
   }
   
   
       window.location.href=encodeURI(searchLink+toPageLink+'&page='+curPage + param);
 }
 
 
 //搜索
function startSearch()
{
   var form =document.forms['ebbEmailManageForm'];
   var senderUserName = form.senderUserName.value;
   var sendTypeId=form.sendTypeId.value;
   var reciverUserName=form.reciverUserName.value;
   var reciverTypeId = form.reciverTypeId.value;
   var title = form.title.value;
   var content = form.content.value;
   var sendTimeStr = form.sendTimeStr.value;
   var sendTimeEndStr = form.sendTimeEndStr.value;
   var mailType = form.mailType.value;
   
   var link="/admin/ebbmail/ebbEmailManageAdmin.do?action=search";
   if(senderUserName!=null  && senderUserName!='')
   {
     link = link+'&senderUserName='+senderUserName;
   }
   
   if(sendTypeId!=null  && sendTypeId!='')
   {
     link = link+'&sendTypeId='+sendTypeId;
   }
   if(reciverUserName!=null  && reciverUserName!='')
   {
     link = link+'&reciverUserName='+reciverUserName;
   }
   if(reciverTypeId!=null  && reciverTypeId!='')
   {
     link = link+'&reciverTypeId='+reciverTypeId;
   }
   if(title!=null  && title!='')
   {
     link = link+'&title='+title;
   }
   if(content!=null  && content!='')
   {
     link = link+'&content='+content;
   }
   if(sendTimeStr!=null  && sendTimeStr!='')
   {
     link = link+'&sendTimeStr='+sendTimeStr;
   }
   if(mailType!=null  && mailType!='')
   {
     link = link+'&mailType='+mailType;
   }
   
   window.location.href=encodeURI(link);
      
}
</script>
</head>

<body>
<div class="vb_wid">&nbsp;【站内短信管理】</div>

<html:form action="/admin/ebbmail/ebbEmailManageAdmin.do?action=search">
<div class="fb_search">
   <h1><span>搜索</span><font><a href="/admin/manage/adminSendEmailSearch.do?action=search">批量发送</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="/admin/emailSend/ebbEmailSendToAll.jsp">发送给同类型用户</a></font></h1>
  <div class="fb_s_a1">
    <label>发件人:
     <input type="text" id="senderUserName" name="senderUserName" size="10" />
    </label>
    <label>
    发件人类型:
    <html:select property="sendTypeId">
      <html:option value="-1">请选择</html:option>
      <html:option value="1">个人</html:option>
      <html:option value="2">招商通</html:option>
      <html:option value="2">网购通</html:option>
      <html:option value="3">管理员</html:option>
    </html:select>
    
    收货人:
    <input type="text" id="reciverUserName" name="reciverUserName" size="10" />
    
     <html:select property="reciverTypeId">
     <html:option value="-1">请选择</html:option>
      <html:option value="1">个人</html:option>
      <html:option value="2">招商通</html:option>
      <html:option value="2">网购通</html:option>
      <html:option value="3">管理员</html:option>
    </html:select>
    <br/>
    标题
    <input type="text" id="title" name="title" size="10" />
    内容
    <input type="text" id="content" name="content" size="10" />
    发送时间:
    <input type="text" id="sendTimeStr" name="sendTimeStr" size="10"  onclick="calendar();"/>
    -
    <input type="text" id="sendTimeEndStr" name="sendTimeEndStr" size="10"  onclick="calendar();" />
    邮件类型
    <html:select property="mailType">
      <html:option value="-1">请选择</html:option>
      <html:option value="oneToOne">个人对个人</html:option>
      <html:option value="all">所有人</html:option>
      <html:option value="zst_all">所有招商通</html:option>
      <html:option value="zst_gold_all">所有招商通(金)</html:option>
      <html:option value="wgt_all">所有网购通</html:option>
      <html:option value="wgt_gold_all">所有网购通(金)</html:option>
    </html:select>
    <br/>
    <input  type="button" id="tijiao" value="搜索" onclick="startSearch();"/>
    </label>
    
  </div>
   <div class="fb_s_a2"></div>
</div>
<div class="fb_nr">
  <table width="100%" border="0" cellspacing="1">
    <tr class="lb">
      <td width="5%">选择</td>
      <td width="9%">发件人</td>
      <td width="8%">发件人类型</td>
      <td width="10%">收件人</td>
      <td width="8%">收件人类型</td>
      <td width="15%" title="发件标题">发件标题</td>	  
      <td width="15%" title="发件内容">发件内容</td>
      <td width="13%" title="发件时间">发件时间</td>
      <td width="8%" title="邮件类型">邮件类型</td>
    </tr>
    <c:if test="${ebbEmailList!=null}">
      <c:forEach items="${ebbEmailList}" var="ebbEmailList" varStatus="ebbEmailListSts" >
            <tr>
            <td title="${ebbEmailList.id}"><input type="checkbox" id="checkboxparam" name="checkboxparam" value="${ebbEmailList.id}" /></td>
            <td>${ebbEmailList.senderUserName}</td>
            <td><c:if test="${ebbEmailList.bmUserTypeBySendType!=null}">${ebbEmailList.bmUserTypeBySendType.userTypeName}</c:if></td>
            <td><c:if test="${ebbEmailList.reciverUserName!=null}">${ebbEmailList.reciverUserName}</c:if></td>
            <td><c:if test="${ebbEmailList.bmUserTypeByReciverType!=null}">${ebbEmailList.bmUserTypeByReciverType.userTypeName}</c:if></td>
            <td title="${ebbEmailList.title}"><c:if test="${ebbEmailList.title!=null}">
            <c:out value="${fn:substring(ebbEmailList.title,0,15)}"/>
            </c:if></td>
            <td title="${ebbEmailList.content}"><c:if test="${ebbEmailList.content!=null}">
            <c:out value="${fn:substring(ebbEmailList.content,0,15)}" escapeXml="true"/>
            </c:if></td>
            <td title="${ebbEmailList.sendTime}">
               <c:if test="${ebbEmailList.sendTime!=null}">
                   <c:out value="${fn:substring(ebbEmailList.sendTime,0,10)}"/>
               </c:if>
            </td>
            <td>
               <c:if test="${ebbEmailList.mailType!=null}">
               <c:choose>
                  <c:when test="${ebbEmailList.mailType=='oneToOne'}">个人对个人</c:when>
                  <c:when test="${ebbEmailList.mailType=='all'}">所有人</c:when>
                  <c:when test="${ebbEmailList.mailType=='wgt_all'}">所有网购通</c:when>
                  <c:when test="${ebbEmailList.mailType=='wgt_gold_all'}">所有网购通金牌用户</c:when>
                  <c:when test="${ebbEmailList.mailType=='zst_all'}">所有招商通用户</c:when>
                  <c:when test="${ebbEmailList.mailType=='zst_gold_all'}">所有招商通金牌用户</c:when>
               </c:choose>
               </c:if>
               </td>
            </tr>
      </c:forEach>
        
    </c:if>
    
	<tr>
      <td colspan="13"><div><label>
      <html:button onclick="selectAll(1);" property="button" value="全选" />
		&nbsp;
		<html:button onclick="selectAll(2);" property="button" value="反选" />
		&nbsp;
	<html:button onclick="selectAll(3);" property="button" value="不选" />
	<html:button onclick="javascript:deleteAll();void 0" property="button" value="批量删除"/>
      </label>
          <label></label>
          <label></label>
          <label></label>
          <label></label>
          <label></label>
      </div></td>
    </tr>
  </table>
</div>
<input id="toPageLink" name="toPageLink" type="hidden"  value="&sendTypeId=${ebbEmailManageForm.sendTypeId==null?'':ebbEmailManageForm.sendTypeId}&reciverTypeId=${ebbEmailManageForm.reciverTypeId==null?'':ebbEmailManageForm.reciverTypeId}&title=${ebbEmailManageForm.title==null?'':ebbEmailManageForm.title}&content=${ebbEmailManageForm.content==null?'':ebbEmailManageForm.content==null}&sendTimeStr=${ebbEmailManageForm.sendTimeStr==null?'':ebbEmailManageForm.sendTimeStr}&sendTimeEndStr=${ebbEmailManageForm.sendTimeEndStr==null?'':ebbEmailManageForm.sendTimeEndStr}&mailType=${ebbEmailManageForm.mailType==null?'':ebbEmailManageForm.mailType}&senderUserName=${ebbEmailManageForm.senderUserName==null?'':ebbEmailManageForm.senderUserName}&reciverUserName=${ebbEmailManageForm.reciverUserName==null?'':ebbEmailManageForm.reciverUserName}" />
<input id="curPage" name="curPage" type="hidden" value="${curPage}"/>
<div class="fy1">
  <font color="red">${curPage}</font>/<font color="red">${allPage}</font>
  	<logic:notEmpty name="recordNum">
	<c:if test="${recordNum>0}">
		<c:if test="${curPage>1}">
		     <html:link href="javascript:toPage(before,${backPage}); void 0;" >上一页</html:link>
		</c:if>
		<%--  页码循环 --%>
		<c:if test="${(curPage>=1)&&(curPage<=7)&&(allPage<8)}">
		<c:forEach begin="${1}" end="${allPage}" var="page" step="1" varStatus="pageCount">
			<b>&nbsp;
			<html:link href="javascript:toPage('curPage',${page}); void 0;" >
				[<c:if test="${curPage==page}">
					<font color="red" class="one">
						<c:out value="${pageCount.index}"></c:out> 
					</font>
				</c:if>
				<c:if test="${curPage!=page}">
						<c:out value="${pageCount.index}"></c:out>
				</c:if>]
			</html:link>
			</b>
		</c:forEach>
		</c:if>
		<c:if test="${(curPage>=1)&&(curPage<=7)&&(allPage>8)}">
		<c:forEach begin="${1}" end="${8}" var="page" step="1" varStatus="pageCount">
			<b>&nbsp;
			<html:link href="javascript:toPage('curPage',${page}); void 0;" >
				[<c:if test="${curPage==page}">
					<font color="red" class="one">
						<c:out value="${pageCount.index}"></c:out> 
					</font>
				</c:if>
				<c:if test="${curPage!=page}">
						<c:out value="${pageCount.index}"></c:out>
				</c:if>]
			</html:link>
			</b>
		</c:forEach>
		</c:if>
		<c:if test="${curPage>7&&(allPage>(curPage+4))}">
		 <html:link href="javascript:toPage('curPage',1); void 0;" >1</html:link>....
		<c:forEach begin="${(curPage-3)}" end="${(curPage+4)}" var="page" step="1" varStatus="pageCount">
			<b>&nbsp;
			<html:link href="javascript:toPage('curPage',${page}); void 0;" >
				[<c:if test="${curPage==page}">
					<font color="red" class="one">
						<c:out value="${pageCount.index}"></c:out> 
					</font>
				</c:if>
				<c:if test="${curPage!=page}">
						<c:out value="${pageCount.index}"></c:out>
				</c:if>]
			</html:link>
			</b>
		</c:forEach>
		</c:if>
		<c:if test="${curPage>7&&(allPage<=(curPage+4))}">
         <html:link href="javascript:toPage('curPage',1); void 0;" >1</html:link>....
		<c:forEach begin="${(curPage-3)}" end="${allPage}" var="page" step="1" varStatus="pageCount">
			<b>&nbsp;
			<html:link href="javascript:toPage('curPage',${page}); void 0;" >
				[<c:if test="${curPage==page}">
					<font color="red" class="one">
						<c:out value="${pageCount.index}"></c:out> 
					</font>
				</c:if>
				<c:if test="${curPage!=page}">
						<c:out value="${pageCount.index}"></c:out>
				</c:if>]
			</html:link>
			</b>
		</c:forEach>
		</c:if>

			<c:if test="${curPage<allPage}">
			<html:link href="javascript:toPage('curPage',${nextPage}); void 0;" >下一页</html:link>
			</c:if>
            <c:if test="${(allPage>1)&&(curPage<allPage)}">
             <html:link href="javascript:toPage('curPage',${allPage}); void 0;" >尾页</html:link>   
			</c:if>
	</c:if>
	</logic:notEmpty>
                到
                 <input id="toPageValue"  name="toPageValue" type="text" size="2"/>
    页&nbsp;
      <input type="button"  value=" " style="background-image: url('/admin/images/ck.gif');border:0px;width:58px;"  title="查看"  onclick="return toPage('toPage','toPage');"/>
    
</div>

</html:form>
  <SCRIPT type=text/javascript>
    Calendar.setup({
        inputField     :    "sendTimeStr",  //sendShopTime2 detailForm:sendShopTime  // id of the input field
        ifFormat       :    "%Y-%m-%d",      // format of the input field
        button         :    "sendTimeStr",  // trigger for the calendar (button ID)
        align          :    "sendTimeStr",           // alignment (defaults to "Bl")
        singleClick    :    true
    });
</SCRIPT>

  <SCRIPT type=text/javascript>
    Calendar.setup({
        inputField     :    "sendTimeEndStr",  //sendShopTime2 detailForm:sendShopTime  // id of the input field
        ifFormat       :    "%Y-%m-%d",      // format of the input field
        button         :    "sendTimeEndStr",  // trigger for the calendar (button ID)
        align          :    "sendTimeEndStr",           // alignment (defaults to "Bl")
        singleClick    :    true
    });
</SCRIPT>

</body>
</html>
